package com.fw.web.controller.system;

import java.util.List;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fw.annotation.Log;
import com.fw.core.controller.BaseController;
import com.fw.core.domain.AjaxResult;
import com.fw.enums.BusinessType;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import javax.validation.Valid;
import static com.fw.mes.ResultUtils.success;
import com.fw.system.admin.domain.TbBond;
import com.fw.system.admin.service.ITbBondService;
import com.fw.utils.poi.ExcelUtil;
import lombok.RequiredArgsConstructor;
import com.fw.core.page.TableDataInfo;

/**
 * 证券知识大课堂Controller
 * 
 * @author yanwei
 * @date 2023-04-04
 */
@Api(tags = "bond")
@RestController
@RequestMapping("/admin/bond")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class TbBondController extends BaseController
{
    @Autowired
    private ITbBondService tbBondService;

    /**
     * 查询证券知识大课堂列表
     */
    @PreAuthorize("@ss.hasPermi('admin:bond:list')")
    @GetMapping("/list")
    @ApiOperation("查询证券知识大课堂列表")
    public TableDataInfo list(TbBond tbBond)
    {
        startPage();
        List<TbBond> list = tbBondService.selectTbBondList(tbBond);
        return getDataTable(list);
    }

    /**
     * 导出证券知识大课堂列表
     */
    @PreAuthorize("@ss.hasPermi('admin:bond:export')")
    @Log(title = "证券知识大课堂", businessType = BusinessType.EXPORT)
    @ApiOperation("导出证券知识大课堂列表")
    @GetMapping("/export")
    public AjaxResult export(TbBond tbBond)
    {
        List<TbBond> list = tbBondService.selectTbBondList(tbBond);
        ExcelUtil<TbBond> util = new ExcelUtil<TbBond>(TbBond.class);
        return util.exportExcel(list, "bond");
    }

    /**
     * 获取证券知识大课堂详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:bond:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取证券知识大课堂详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tbBondService.selectTbBondById(id));
    }

    /**
     * 新增证券知识大课堂
     */
    @PreAuthorize("@ss.hasPermi('admin:bond:add')")
    @Log(title = "证券知识大课堂", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增证券知识大课堂")
    public AjaxResult add(@RequestBody TbBond tbBond)
    {
        return toAjax(tbBondService.insertTbBond(tbBond));
    }

    /**
     * 修改证券知识大课堂
     */
    @PreAuthorize("@ss.hasPermi('admin:bond:edit')")
    @Log(title = "证券知识大课堂", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改证券知识大课堂")
    public AjaxResult edit(@RequestBody TbBond tbBond)
    {
        return toAjax(tbBondService.updateTbBond(tbBond));
    }

    /**
     * 删除证券知识大课堂
     */
    @PreAuthorize("@ss.hasPermi('admin:bond:remove')")
    @Log(title = "证券知识大课堂", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除证券知识大课堂")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbBondService.deleteTbBondByIds(ids));
    }
}
